﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace InfoPick.Lib.DataProvider
{
    public abstract class DataProvider : IDataProvider
    {
        protected static Dictionary<string, string> dict = new Dictionary<string, string>();

        static DataProvider()
        {
            string[] keys = new string[] { "TDMIU", "E32", "S1L", "S2L", "EPI" ,"CSU","N7LNKALL","N7LNK",
                "AIETKC","N7TKC", "AIETG","MTP2LNK","CLKSRC"};
            foreach (var key in keys)
            {
                dict.Add(key, ConfigurationManager.AppSettings[key]);
            }
        }

        /// <summary>
        /// 必须显示调用此函数
        /// 初始化socket连接以及文件io
        /// </summary>
        public abstract bool Begin();

        /// <summary>
        /// 必须显示调用此函数
        /// 释放内置的socket连接以及文件io
        /// </summary>
        public abstract void Complete();

        protected Action<string> onNotice;
        public virtual Action<string> OnNotice
        {
            get
            {
                return onNotice;
            }
            set
            {
                onNotice = value;
            }
        }

        protected Action<string, string> onCmdSuccess;
        public virtual Action<string, string> OnCmdSuccess
        {
            get
            {
                return onCmdSuccess;
            }
            set
            {
                onCmdSuccess = value;
            }
        }

        protected void Notice(string msg)
        {
            if (OnNotice != null)
                OnNotice(msg);
        }

        protected virtual void CmdSuccess(string cmd, string res)
        {
            if (OnCmdSuccess != null)
            {
                OnCmdSuccess(cmd, res);
            }
        }


        public abstract string GetTdmiuList();

        public abstract string GetE32List();

        public abstract string GetS2lList();

        public abstract string GetEpiList();

        public abstract string GetCsuList();

        public abstract string GetN7LNKALLList();

        public abstract string GetN7TKCList();

        public abstract string GetAIETKCList();


        public abstract string GetAIETGList();


        public abstract string GetN7LNKList();

        public abstract string GetMTP2LNKAllList();

        public abstract string GetMTP2LNKList(int key);

        public abstract string GetCLKSRCList();
    }


    public enum ServerType
    {
        MGW,
        MSC
    }
}
